import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_base_widget/base/base.dart';

class AlertPage extends BasePage {
  @override
  // TODO: implement title
  String get title => "AlertPage";

  Future<void> _neverSatisfied(BuildContext context) async {
    return showDialog<void>(
      context: context,
      barrierDismissible: false, // user must tap button!
      builder: (BuildContext context) {
        return AlertDialog(
          title: Text('Rewind and remember'),
          content: SingleChildScrollView(
            child: ListBody(
              children: <Widget>[
                Text('You will never be satisfied.'),
                Text('You\’re like me. I’m never satisfied.'),
                Text('You\’re like me. I’m never satisfied.'),
                Text('You\’re like me. I’m never satisfied.'),
                Text('You\’re like me. I’m never satisfied.'),
                Text('You\’re like me. I’m never satisfied.'),
                Text('You\’re like me. I’m never satisfied.'),
                Text('You\’re like me. I’m never satisfied.'),
              ],
            ),
          ),
          actions: <Widget>[
            FlatButton(
              child: Text('Regret'),
              onPressed: () {
                Navigator.of(context).pop();
              },
            ),
          ],
        );
      },
    );
  }

  Future<void> _iosneverSatisfied(BuildContext context) async {
    return showCupertinoDialog<void>(
      context: context,
      builder: (BuildContext context) {
        return CupertinoAlertDialog(
          title: Text("提示"),
          content: SingleChildScrollView(
            child: ListBody(
              children: <Widget>[
                Text('You will never be satisfied.'),
                Text('You\’re like me. I’m never satisfied.'),
                Text('You\’re like me. I’m never satisfied.'),
                Text('You\’re like me. I’m never satisfied.'),
                Text('You\’re like me. I’m never satisfied.'),
                Text('You\’re like me. I’m never satisfied.'),
                Text('You\’re like me. I’m never satisfied.'),
                Text('You\’re like me. I’m never satisfied.'),
              ],
            ),
          ),
          actions: <Widget>[
            FlatButton(
              child: Text('Regret'),
              onPressed: () {
                Navigator.of(context).pop();
              },
            ),
            FlatButton(
              child: Text('right'),
              onPressed: () {
                Navigator.of(context).pop();
              },
            ),
          ],
        );
      },
    );
  }

  @override
  Widget rebuild(BuildContext context) {
    return Center(
      child: Column(
        children: <Widget>[
          RaisedButton(
          child: Text("normal"),
          onPressed: (){
            _neverSatisfied(context);
          }),
          RaisedButton(
          child: Text("ios alert"),
          onPressed: (){
            _iosneverSatisfied(context);
          }),
        ],
      ),
    );
  }
}